package com.qf.java2201.web;

import com.qf.java2201.pojo.HOrder;
import com.qf.java2201.pojo.HUser;
import com.qf.java2201.service.OrderService;
import com.qf.java2201.service.impl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

/**
 * @date 2022/4/9
 * @desc
 */
@WebServlet("/showOrder")
public class ShowOrderServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


        HttpSession session = req.getSession();

        HUser hUser = (HUser) session.getAttribute("u");
        //查询当前用户的预约单

        OrderService orderService = new OrderServiceImpl();


        List<HOrder> horders = orderService.findOrderByUdid(hUser.getUi().getDid());


        session.setAttribute("os",horders);

        resp.sendRedirect("/info.jsp");
    }
}
